package com.gitee.wsl.doc.prosemirror.history.ext

import com.gitee.wsl.doc.prosemirror.history.HistoryOptions
import com.gitee.wsl.doc.prosemirror.history.bean.HistoryState
import com.gitee.wsl.doc.prosemirror.history.mustPreserveItems
import com.gitee.wsl.doc.prosemirror.history.rangesFor
import com.gitee.wsl.doc.prosemirror.state.EditorState
import com.gitee.wsl.doc.prosemirror.state.Transaction

fun HistoryState.redo(state: EditorState,
                      tr: Transaction,
                      options: HistoryOptions
) = HistoryState(
    done.addTransform(tr, null, options, state.mustPreserveItems()),
    undone,
    rangesFor(tr.mapping.maps),
    prevTime,
    prevComposition
)